﻿function GetParamValue() {
    var query = '?QueryName=' + $('#hfCurQueryName').val();
    $('#panelStdQueryParam > div:not(:last)').each(function () {
        var id = $(this).attr('id').replace('Field_', '');
        var paramType = $(this).attr("ParamType").toUpperCase();
        if (id.length != 0) {
            if (paramType.indexOf("DATE") != -1) {
                query += '&' + id + '=' + $(this).find('input:visible').val();
            }
            else if (paramType.indexOf("STORENO") != -1) {
                query += '&' + id + '=' + $(this).find('input').val().split('.')[0];
            } else if (paramType.indexOf("MONTH") != -1 || paramType.indexOf("WEEK") != -1) {
                var two = $(this).find("input:eq(1)").val();
                if (two.length == 1) two = "0" + two;

                query += '&' + id + '=' + $(this).find("input:eq(0)").val() + two;
            } else if (paramType.indexOf("PROPERTY") != -1) {
                var v = 0;
                $(this).find("input:checkbox[checked]").each(function () {
                    v += parseInt($(this).parents("table").attr("chkValue"));
                });
                query += '&' + id + '=' + v;
            }
            else if (paramType.indexOf("STDQUERY") != -1) {
                query += '&' + id + '=' + $(this).find('input').val().split('.')[0];
            }
            else
                query += '&' + id + '=' + $(this).find('input').val();
        }
    });
    return query;
}

function BtnDialogSel(s, e) {
    var dialog = $(s.inputElement).parent().parent().parent().parent();
    var url = dialog.attr("url");

    var dialogSelIndex = parent.parent.$("#hiddenDialogSelIndex");
    var dialogIndex = dialogSelIndex.val();
    var targetID = "";
    if (parent.frameElement == undefined) {
        targetID = self.frameElement.id + "." + s.uniqueID.replace("$", "_");
    } else {
        targetID = parent.frameElement.id + "." + self.frameElement.id + "." + s.uniqueID.replace("$", "_");
    }

    eval("parent.parent.dialogSel" + dialogIndex + ".targetID='" + targetID + "'");
    eval("parent.parent.dialogSel" + dialogIndex + ".SetContentUrl('" + url + "')");


    //    parent.parent.dialogSel.targetID = targetID;
    //    parent.parent.dialogSel.SetContentUrl(url);
    if (url.indexOf("DialogTreeSel.aspx") != -1) {
        eval("parent.parent.dialogSel" + dialogIndex + ".SetSize(300, 500)");
        //parent.parent.dialogSel.SetSize(300, 500);
    } else if (url.indexOf("DialogGridSel.aspx") != -1) {
        //parent.parent.dialogSel.SetSize(900, 600);
        eval("parent.parent.dialogSel" + dialogIndex + ".SetSize(900, 600)");
    }
    eval("parent.parent.dialogSel" + dialogIndex + ".Show()");
    //parent.parent.dialogSel.Show();
    //    dialogSelIndex.val((parseInt(dialogIndex) + 1));
    e.processOnServer = false;
}